home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 22 April 1997
- // Author: sjt
- //
- // Description:
- // Initialize the option values.
- //
- // Input Arguments:
- // int action
- // 0 - just execute the extend curve operation
- // 1 - show the option box dialog
- // 2 - drag to shelf
- //
- // Return Value:
- // None.
- //
- // Notes:
- // In the future this can be modified to include extend to object
- //
- global proc extendCosCurveEnableBoth( string $joinWidget,
- string $methodWidget,
- string $endWidget,
- string $knotsWidget,
- string $originalsWidget,
- int $priorityEnd )
- {
- int $enable;
- if( $priorityEnd ) {
- int $end = `radioButtonGrp -q -select $endWidget`;
- if( 3 == $end ) {
- $enable = 0;
- }
- else {
- $enable = 1;
- }
- radioButtonGrp -edit -enable2 $enable $methodWidget;
- checkBoxGrp -edit -enable $enable $joinWidget;
-
- $enable = `checkBoxGrp -q -value1 $joinWidget`;
- checkBoxGrp -edit -enable $enable $knotsWidget;
- checkBoxGrp -edit -enable $enable $originalsWidget;
- }
- else {
- int $join = `checkBoxGrp -q -value1 $joinWidget`;
- int $method = `radioButtonGrp -q -select $methodWidget`;
- if( $join && (1 == $method)) {
- $enable = 1;
- }
- else {
- $enable = 0;
- }
-
- radioButtonGrp -edit -enable3 $enable $endWidget;
-
- $enable = $join;
- checkBoxGrp -edit -enable $enable $knotsWidget;
- checkBoxGrp -edit -enable $enable $originalsWidget;
- }
- }
-
- proc setOptionVars(int $forceFactorySettings)
- {
- // ExtendCos Method ( 0 = by distance or 2 = to point ).
- // Default = 0 = by distance
- //
- if ($forceFactorySettings || !`optionVar -exists extendCosCurveMethod`) {
- optionVar -intValue extendCosCurveMethod 0;
- }
-
- // Extension Type ( 0 = linear or 1 = cicular or 2 = extrapolate ).
- // Used only if extend method is 0
- // Default = 0 = linear
- //
- if ($forceFactorySettings || !`optionVar -exists extendCosCurveType`) {
- optionVar -intValue extendCosCurveType 2;
- }
-
- // Extend Distance.
- // Used only if extend method is 0
- // Default = 1.00
- //
- if ($forceFactorySettings || !`optionVar -exists extendCosCurveDistance`) {
- optionVar -floatValue extendCosCurveDistance 0.1;
- }
-
- // Extend To Point.
- // Used only if extend method is 2
- // Default = 0.0, 0.0, 0.0
- //
- if ($forceFactorySettings || !`optionVar -exists extendCosCurveToPointU`) {
- optionVar -floatValue extendCosCurveToPointU 0.0;
- }
- if ($forceFactorySettings || !`optionVar -exists extendCosCurveToPointV`) {
- optionVar -floatValue extendCosCurveToPointV 0.0;
- }
-
-
- // Extend Start ( 1 = start or 0 = end, 2 = both )
- // Default = 0
- //
- if ($forceFactorySettings || !`optionVar -exists extendCosCurveStart`) {
- optionVar -intValue extendCosCurveStart 0;
- }
-
- // Extend Join ( on = join or off = do not join )
- // Default = ON
- //
- if ($forceFactorySettings || !`optionVar -exists extendCosCurveJoin`) {
- optionVar -intValue extendCosCurveJoin 1;
- }
-
- // Extend Remove Multiple Knots ( on = remove or off = do not remove )
- // Used only when joining
- // Default = OFF
- //
- if ($forceFactorySettings ||
- !`optionVar -exists extendCosCurveRemoveMultKnots`) {
- optionVar -intValue extendCosCurveRemoveMultKnots 1;
- }
-
- // keep original (for in place operations is on-1 or off-0 )
- // Used only when joining
- /// Default = 0
- //
- if ($forceFactorySettings ||
- !`optionVar -exists extendCosCurveKeepOriginal`) {
- optionVar -intValue extendCosCurveKeepOriginal 0;
- }
-
- }
-
- //
- // Procedure Name:
- // extendCosCurveSetup
- //
- // Description:
- // Update the state of the option box UI to reflect the extend curve
- // option values.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- //
- // forceFactorySettings - Whether the option values should be set to
- // default values.
- //
- // Return Value:
- // None.
- //
- global proc extendCosCurveSetup( string $parent,
- int $forceFactorySettings,
- string $goToTool )
- {
- // Retrieve the option settings
- //
- setOptionVars($forceFactorySettings);
- extendCosCurveToolSetup( $forceFactorySettings, $goToTool );
-
- setParent $parent;
-
- // Query the optionVar's and set the values into the controls.
-
- // Extend Method
- //
- int $method = `optionVar -query extendCosCurveMethod`;
- radioButtonGrp -e -sl ($method+1) extendCosCurveMethodBtn;
-
- // extend distance
- floatSliderGrp -edit
- -value `optionVar -query extendCosCurveDistance`
- extendCosCurveDistanceSlider;
-
- // extend type
- int $extendType = `optionVar -query extendCosCurveType`;
- int $realExtendType = $extendType + 1 ;
- radioButtonGrp -edit
- -select $realExtendType
- extendCosCurveTypeBtn;
-
- // extend point
- float $u = `optionVar -q extendCosCurveToPointU`;
- float $v = `optionVar -q extendCosCurveToPointV`;
- floatFieldGrp -e -v1 $u extendCosCurveToPointFloatFieldGrp;
- floatFieldGrp -e -v2 $v extendCosCurveToPointFloatFieldGrp;
-
-
- // extend start and join
- //
- int $join = `optionVar -query extendCosCurveJoin`;
- int $start = `optionVar -query extendCosCurveStart`;
-
- // convert from value to button number
- // ( 1 = start or 0 = end, 2 = both )
- switch( $start ) {
- case 0:
- $start = 2;
- break;
- case 1:
- $start = 1;
- break;
- case 2:
- default:
- $start = 3;
- break;
- }
-
- radioButtonGrp -e
- extendCosCurveMethodBtn;
-
- radioButtonGrp -edit
- -select $start
- extendCosCurveStartBtn;
-
- // Extend join
- //
- checkBoxGrp -edit
- -value1 $join
- extendCosCurveJoinBox;
-
- // Remove Multiple Knots
- //
- checkBoxGrp -edit
- -value1 `optionVar -query extendCosCurveRemoveMultKnots`
- -enable ($join && (3 != $start))
- extendCosCurveRemoveMultKnotsBox;
-
- // Keep original.
- //
- checkBoxGrp -edit
- -value1 `optionVar -query extendCosCurveKeepOriginal`
- -enable ($join && (3 != $start))
- extendCosCurveKeepOriginalBox;
-
- extendCosCurveEnableBoth( "extendCosCurveJoinBox",
- "extendCosCurveMethodBtn",
- "extendCosCurveStartBtn",
- "extendCosCurveRemoveMultKnotsBox",
- "extendCosCurveKeepOriginalBox",
- 0 );
-
- // Do the visibility here (distance vs. point):
- if( 0 == $method ) {
- tabLayout -e -st extendCosCurveDistance_tab extendCosCurveMethodOptions;
- }
- else {
- tabLayout -e -st extendCosCurveToPoint_tab extendCosCurveMethodOptions;
- }
-
- if( "" != $goToTool ) {
- checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool`
- scriptToolExtraWidget;
- checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
- scriptToolExtraWidget;
- }
- }
-
- //
- // Procedure Name:
- // extendCurveCallback
- //
- // Description:
- // Update the option values with the current state of the option box UI.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI. Required so
- // that UI object names can be successfully resolved.
- //
- // doIt - Whether the command should execute.
- //
- // Return Value:
- // None.
- //
- global proc extendCosCurveCallback(string $parent, int $doIt, string $goToTool)
- {
- if( "" != $goToTool ) {
- optionVar -iv extendCosCurveEuc `scriptCtx -q -euc $goToTool`;
- optionVar -iv extendCosCurveLac `scriptCtx -q -lac $goToTool`;
- }
- setParent $parent;
-
- // Set the optionVar's from the control values, and then
- // perform the command.
-
- // Extend Method.
- //
- int $method = `radioButtonGrp -query -select extendCosCurveMethodBtn`;
- int $saveMethod = $method - 1 ;
- optionVar -intValue extendCosCurveMethod $saveMethod;
-
- if( $saveMethod == 0 ) {
- // Extend Type
- //
- int $extendType = `radioButtonGrp -query -select extendCosCurveTypeBtn`;
- int $saveExtendType = $extendType - 1 ;
- optionVar -intValue extendCosCurveType $saveExtendType;
-
- // extend distance
- //
- optionVar -floatValue extendCosCurveDistance
- `floatSliderGrp -query -value extendCosCurveDistanceSlider`;
- }
- else {
- // extend to point.
- //
- float $u = `floatFieldGrp -q -v1 extendCosCurveToPointFloatFieldGrp` ;
- float $v = `floatFieldGrp -q -v2 extendCosCurveToPointFloatFieldGrp` ;
- optionVar -floatValue extendCosCurveToPointU $u ;
- optionVar -floatValue extendCosCurveToPointV $v ;
- }
-
- // Start or end or both
- // ( 1 = start or 0 = end, 2 = both )
- int $start = `radioButtonGrp -query -select extendCosCurveStartBtn`;
-
- // convert from button number to value
- switch( $start ) {
- case 1:
- $start = 1;
- break;
- case 2:
- $start = 0;
- break;
- case 3:
- default:
- $start = 2;
- break;
- }
- optionVar -intValue extendCosCurveStart $start;
-
- // Join
- //
- optionVar -intValue extendCosCurveJoin
- `checkBoxGrp -query -value1 extendCosCurveJoinBox`;
-
- // Remove Multiple knots
- //
- optionVar -intValue extendCosCurveRemoveMultKnots
- `checkBoxGrp -query -value1 extendCosCurveRemoveMultKnotsBox`;
-
- // Keep original.
- //
- optionVar -intValue extendCosCurveKeepOriginal
- `checkBoxGrp -query -value1 extendCosCurveKeepOriginalBox`;
-
- if (1 == $doIt) {
- performExtendCosCurve( 0, $goToTool );
- string $tmpCmd = "performExtendCosCurve(0, \"" + $goToTool +"\")";
- addToRecentCommandQueue $tmpCmd "Extend Curve On Surface";
- }
- else if( $doIt ) {
- setToolTo $goToTool;
- }
- }
-
- //
- // Procedure Name:
- // createExtendCosCurveUI
- //
- // Description:
- // Fill the contents of the option box for extendCurve command.
- //
- // Input Arguments:
- // The name of the parent layout.
- //
- // Return Value:
- // None.
- //
- proc createExtendCosCurveUI(string $parent, int $inTheTool, string $goToTool)
- {
- setParent $parent;
-
- string $methodWidget = `radioButtonGrp -label "Extend Method"
- -numberOfRadioButtons 2
- -label1 "Parametric Distance" -da1 0
- -label2 "UV Point" -da2 2
- extendCosCurveMethodBtn`;
-
- tabLayout -tabsVisible false extendCosCurveMethodOptions;
- columnLayout extendCosCurveDistance_tab;
- radioButtonGrp -label "Extension Type"
- -numberOfRadioButtons 3
- -label1 "Linear" -da1 0
- -label2 "Circular" -da2 1
- -label3 "Extrapolate" -da3 2
- extendCosCurveTypeBtn;
-
- floatSliderGrp -label "Parametric Distance"
- -field true
- -min 0.0
- -max 100.0
- extendCosCurveDistanceSlider;
- setParent ..;
-
- columnLayout extendCosCurveToPoint_tab;
- floatFieldGrp -l "UV Point To Extend To"
- -nf 2
- extendCosCurveToPointFloatFieldGrp;
- setParent ..;
- setParent ..;
-
- separator;
-
- string $endWidget = `radioButtonGrp -label "Extend Curve at"
- -numberOfRadioButtons 3
- -label1 "Start" -da1 1 -enable1 1
- -label2 "End" -da2 0 -enable2 1
- -label3 "Both" -da3 0 -enable3 1
- extendCosCurveStartBtn`;
-
- string $joinWidget = `checkBoxGrp -label ""
- -numberOfCheckBoxes 1
- -label1 "Join to Original"
- extendCosCurveJoinBox`;
-
- string $knotsWidget = `checkBoxGrp -label ""
- -numberOfCheckBoxes 1
- -label1 "Remove Multiple Knots"
- extendCosCurveRemoveMultKnotsBox`;
-
- string $originalsWidget = `checkBoxGrp -label ""
- -numberOfCheckBoxes 1
- -label1 "Keep Original"
- extendCosCurveKeepOriginalBox`;
-
- radioButtonGrp -edit
- -onCommand1 (
- "tabLayout -e -selectTab extendCosCurveDistance_tab " +
- "extendCosCurveMethodOptions;"
- + "extendCosCurveEnableBoth"
- + " " + $joinWidget
- + " " + $methodWidget
- + " " + $endWidget
- + " " + $knotsWidget
- + " " + $originalsWidget + " 0;"
- )
- -onCommand2 (
- "tabLayout -e -selectTab extendCosCurveToPoint_tab " +
- "extendCosCurveMethodOptions;"
- + "extendCosCurveEnableBoth"
- + " " + $joinWidget
- + " " + $methodWidget
- + " " + $endWidget
- + " " + $knotsWidget
- + " " + $originalsWidget + " 0;"
- )
- $methodWidget;
-
- radioButtonGrp -edit
- -onCommand1 (
- "extendCosCurveEnableBoth"
- + " " + $joinWidget
- + " " + $methodWidget
- + " " + $endWidget
- + " " + $knotsWidget
- + " " + $originalsWidget + " 1;"
- )
- -onCommand2 (
- "extendCosCurveEnableBoth"
- + " " + $joinWidget
- + " " + $methodWidget
- + " " + $endWidget
- + " " + $knotsWidget
- + " " + $originalsWidget + " 1;"
- )
- -onCommand3 (
- "extendCosCurveEnableBoth"
- + " " + $joinWidget
- + " " + $methodWidget
- + " " + $endWidget
- + " " + $knotsWidget
- + " " + $originalsWidget + " 1;"
- )
- $endWidget;
-
- checkBoxGrp -edit
- -onCommand (
- "extendCosCurveEnableBoth"
- + " " + $joinWidget
- + " " + $methodWidget
- + " " + $endWidget
- + " " + $knotsWidget
- + " " + $originalsWidget + " 0;"
- )
- -offCommand (
- "extendCosCurveEnableBoth"
- + " " + $joinWidget
- + " " + $methodWidget
- + " " + $endWidget
- + " " + $knotsWidget
- + " " + $originalsWidget + " 0;"
- )
- $joinWidget;
-
- if( $inTheTool ) {
- separator;
- checkBoxGrp -ncb 2 -l "Tool Behavior"
- -l1 "Exit on Completion"
- -v1 off
- -on1 ("scriptCtx -e -euc true " + $goToTool)
- -of1 ("scriptCtx -e -euc false " + $goToTool)
-
- -l2 "Auto Completion"
- -v2 on
- -on2 ("scriptCtx -e -lac true " + $goToTool)
- -of2 ("scriptCtx -e -lac false " + $goToTool)
- scriptToolExtraWidget;
- }
- }
-
-
- //
- // Procedure Name:
- // extendCosCurveOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc extendCosCurveOptions( int $inTheTool, string $goToTool )
- {
- // Name of the command for this option box.
- //
- string $commandName = "extendCosCurve";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- global string $gOptionBoxActionToolItem;
- $gOptionBoxActionToolItem = "modelWithToolExtendCosCurve";
- global string $gOptionBoxActionToolItemCB;
- $gOptionBoxActionToolItemCB = "extendCosCurveToolScript 3";
-
- // The value returned is the name of the layout to be used as
- // the parent for the option box UI.
- //
- string $layout = getOptionBox();
- setParent $layout;
-
- // Pass the command name to the option box.
- //
- // Any default option box behavior based on the command name is set
- // up with this call. For example, updating the 'Help' menu item with
- // the name of the command.
- //
- setOptionBoxCommandName($commandName);
-
- // Activate the default UI template so that the layout of this
- // option box is consistent with the layout of the rest of the
- // application.
- //
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- // RECOMMENDATION: Place the UI in a scroll layout. If the
- // option box window is ever resized such that it's entire
- // contents is not visible then the scroll bars provided by the
- // scroll layout will allow the user to access the hidden UI.
- //
- tabLayout -scr true -tv false;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- // Create the UI for the tab that is initially visible.
- //
- createExtendCosCurveUI($parent, $inTheTool, $goToTool);
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Deactivate the default UI template.
- //
- setUITemplate -popTemplate;
-
- // Provide more descriptive labels for the buttons. This is not
- // necessary, but in some cases, for example, a button labelled
- // 'Create' may be more meaningful to the user than one labelled
- // 'Apply'.
- //
- // Disable those buttons that are not applicable to the option box.
- //
- // Attach actions to those buttons that are applicable to the option
- // box. Note that the 'Close' button has a default action attached
- // to it that will hide the window. If a a custom action is
- // attached to the 'Close' button then be sure to call the 'hide the
- // option box' procedure within the custom action so that the option
- // box is hidden properly.
-
- // 'ExtendCurve' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- if( $inTheTool ) {
- button -edit -l "Extend CoS Tool"
- -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"")
- $applyBtn;
- }
- else {
- button -edit -l "Extend CoS"
- -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"")
- $applyBtn;
- }
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " 0 \"" +
- $goToTool + "\"; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
- $resetBtn;
-
- // Set the option box title.
- //
- if( $inTheTool ) {
- setOptionBoxTitle("Extend Curve on Surface Tool Options");
- }
- else {
- setOptionBoxTitle("Extend Curve on Surface Options");
- }
-
- // Customize the 'Help' menu item text.
- //
- setOptionBoxHelpTag( "ExtendCurveOnSurface" );
-
- // Set the current values of the option box.
- //
- eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");
-
- // Show the option box.
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // extendCosCurveHelp
- //
- // Description:
- // Return a short description about this command.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
- proc string extendCosCurveHelp()
- {
- return
- " Command: extendCurve -cos - extends a curve on surface\n" +
- "Selection: a curve on surface ";
- }
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the command that will apply the option box values.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // The extendCurve command string.
- //
- proc string assembleCmd()
- {
- setOptionVars(false);
-
- // get the global history flag value
- int $doHistory = `constructionHistory -q -tgl`;
-
- int $method = `optionVar -query extendCosCurveMethod`;
- int $extendType = `optionVar -query extendCosCurveType`;
- float $distance = `optionVar -query extendCosCurveDistance`;
- float $toPointu = `optionVar -query extendCosCurveToPointU`;
- float $toPointv = `optionVar -query extendCosCurveToPointV`;
-
- int $start = `optionVar -query extendCosCurveStart`;
- int $join = `optionVar -query extendCosCurveJoin`;
- int $removeMultKnots = `optionVar -query extendCosCurveRemoveMultKnots`;
- int $replaceOriginal = !`optionVar -q extendCosCurveKeepOriginal`;
- string $version = "\"2\"";
-
-
- // set up string for preset function call
- // Note that extendCurvePresetArgList() takes a string array.
- // The command will look something like:
- // extendCurvePresetArgList( "2", {"1", "1","0","1",...,"1","1","0"} );
- //
- string $cmd = "extendCurvePresetArgList";
- $cmd = $cmd + "( ";
- $cmd = $cmd + $version;
- $cmd = $cmd + ", { \"1\", \"" ;
- $cmd = $cmd + $doHistory;
- $cmd = $cmd + "\",\"";
- $cmd = $cmd + $method;
- $cmd = $cmd + "\",\"";
- $cmd = $cmd + $extendType;
- $cmd = $cmd + "\",\"";
- $cmd = $cmd + $distance;
- $cmd = $cmd + "\",\"";
- $cmd = $cmd + $toPointu;
- $cmd = $cmd + "\",\"";
- $cmd = $cmd + $toPointv;
- $cmd = $cmd + "\", \"0\", \"";
- $cmd = $cmd + $start;
- $cmd = $cmd + "\",\"";
- $cmd = $cmd + $join;
- $cmd = $cmd + "\",\"";
- $cmd = $cmd + $removeMultKnots;
- $cmd = $cmd + "\",\"";
- $cmd = $cmd + $replaceOriginal;
- $cmd = $cmd + "\" } )";
-
- return $cmd;
- }
-
- //
- // Procedure Name:
- // performExtendCosCurve
- //
- // Description:
- // Perform the optionBoxExample1 command using the corresponding
- // option values. This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the optionBoxExample1 command with the current
- // option box values.
- //
- // Input Arguments:
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- //
- // Return Value:
- // None.
- //
- global proc string performExtendCosCurve(int $action, string $goToTool )
- {
- int $inTheTool = false;
- if( 3 == $action ) {
- $action = 1;
- $inTheTool = true;
- }
-
- string $cmd = "";
- switch ($action) {
-
- case 0:
- setOptionVars(false);
- $cmd = `assembleCmd`;
- eval($cmd);
- break;
-
- case 1:
- extendCosCurveOptions( $inTheTool, $goToTool );
- break;
-
- case 2:
- default:
- setOptionVars (false);
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-
-